package digui;
 class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode() {}
      TreeNode(int val) { this.val = val; }
      TreeNode(int val, TreeNode left, TreeNode right) {
          this.val = val;
          this.left = left;
          this.right = right;
      }
}
public class Text1 {
    //题目 ： 力扣 814题 二叉树的剪枝
    public TreeNode pruneTree(TreeNode root) {
        //递归出口
        if(root == null) {
            return null;
        }

        root.left = pruneTree(root.left);
        root.right = pruneTree(root.right);
        if(root.val == 0 && root.left == null && root.right == null) {
            return null; //剪枝
        }
        return root;
    }

    public static void main(String[] args) {

    }
}
